#!/usr/bin/python
#coding=utf-8

import sys
sys.path.append('..\..')
import parser_excel.parser_excel as parser
import unittest

class test(unittest.TestCase):
	OkValues = ( 

("1.csv", [], 
{
'_test_2': 
	{'PRICE': 1, 'STR': ''}, 
'_test_3': 
	{'PRICE': '', 'STR': '4'}
}),

("2.csv", [], 
{
'_test_6': 
	{'PRICE': 1.0, 'STR': 'Q'}, 
'ST': 
	{'PRICE': 3.0, 'STR': 'E'}
}),

("3.csv", [], 
{
'_test_9': 
	{'KEY3': '11', 'KEY2': 10.0, 'KEY1': 31.5, 'KEY4': 28.0}, 
'STR1': 
	{'KEY3': '7', 'KEY2': 6.0, 'KEY1': 5.0, 'KEY4': 2.0}, 
'STR0': 
	{'KEY3': '3', 'KEY2': 2.0, 'KEY1': -2.0, 'KEY4': 2.0}
}),

("4.csv", [], 
{
'_test_4': 
	{'KEY1': 29.0, 'KEY2': '', 'KEY3': '11', 'KEY4': ''}, 
'STR1': 
	{'KEY1': 5.0, 'KEY2': 6.0, 'KEY3': '7', 'KEY4': ''}, 
'STR0': 
	{'KEY1': 15.5, 'KEY2': 15.5, 'KEY3': '1-5*6+3', 'KEY4': ''}
}),

("5.csv", [], 
{
'ST1': 
	{'HIDDEN': 39, 'PRICE': 0.333333333333, 'SETTLEDATE': '20130112', 
	 'ACTIVATIONTIME': '103712', 'STRKEY': 'DIMAIV'}, 
'ST2': 
	{'HIDDEN': -2, 'PRICE': 1.8, 'SETTLEDATE': '19950516', 
	 'ACTIVATIONTIME': '142312', 'STRKEY': 'REST'}
}),

("6.csv", ["newWord"], 
{
'ST1': 
	{'HIDDEN': 1}, 
'ST2': 
	{'HIDDEN': 1}
})

)	

	def testCalcOk(self):
		for excel, page, res in self.OkValues:
			result = parser.ParseExcel(excel, page).data()
			self.assertEqual(res, result)
			
			#print result

	#def testCalcError(self):
#		for s, d in self.ErrorValues:
#			self.assertRaises(calc.CalcError, calc.formula, s, d)

if __name__ == '__main__':
	unittest.main()